@include('admin.layout.css')
@include('admin.layout.js')




<div class="layui-form" lay-filter="layuiadmin-app-form-list" id="layuiadmin-app-form-list" style="padding: 20px 30px 0 0;">

    <div class="layui-form-item">
        <label class="layui-form-label"> 科普状态</label>
        <div class="layui-input-block">
            <input type="radio" name="show" value="0" title="隐藏" >
            <input type="radio" name="show" value="1" title="显示" >
        </div>
    </div>



    <div class="layui-form-item">
        <label class="layui-form-label"> 科普名称</label>
        <div class="layui-input-block">
            <input type="text"  name="sciences_title"  placeholder="请输入 科普名称" autocomplete="off" class="layui-input" >
        </div>
    </div>


    <div class="layui-form-item">
        <label class="layui-form-label"> 封面图片</label>
        <div class="layui-input-block">
            <button type="button" class="layui-btn" id="test1">上传图片</button>
            <input type="hidden" name="sciences_img" id="img_url">
            <div class="layui-upload-list" >
                <img class="layui-upload-img"  id="img_url_show" width="92px" height="92px">
                <p id="demoText"></p>
            </div>
        </div>
    </div>




    <div class="layui-form-item">
        <label class="layui-form-label"> 详情</label>
        <div class="layui-input-block">
            <textarea name="content1"  id="content1"></textarea>
        </div>
    </div>





    <div class="layui-form-item layui-hide">
        <input type="button" lay-submit lay-filter="submit" id="submit" value="确认">
        <input type="button" lay-submit lay-filter="layuiadmin-app-form-edit" id="layuiadmin-app-form-edit" value="取消">
    </div>

</div>
<script src="/static/admin_templete/ueditor/ueditor.config.js"></script>
<script src="/static/admin_templete/ueditor/ueditor.all.min.js"></script>

<script>
    var ue1 = UE.getEditor('content1',{
        initialFrameWidth:'450'  //初始化编辑器宽度,默认1000
        ,initialFrameHeight:'360'  //初始化编辑器高度,默认320
    });


    UE.Editor.prototype._bkGetActionUrl = UE.Editor.prototype.getActionUrl;
    UE.Editor.prototype.getActionUrl = function(action) {
        if (action == 'uploadimage') {
            return "{{route('admin.local1')}}";
        } else {
            return this._bkGetActionUrl.call(this, action);
        }
    }



</script>

<script>



    UI.upload('#test1',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show').attr('src',res['data']['src']);
            $('#img_url').val(res['data']['src']);
        }
    });

    UI.upload('#test2',function (res) {
        if (res.code !== 200) {
            Utils.errorToast(res.msg);
        }else{
            Utils.successToast('上传成功');
            $('#img_url_show1').attr('src',res['data']['src']);
            $('#img_url1').val(res['data']['src']);
        }
    });

    layui.use(['laydate','form'], function() {
        let form = layui.form;
        form.on('submit(submit)', function(data){
            data.field['content_value'] = ue1.getContent();
            Api.add("{{route('admin.sciences.add')}}",data.field,function(res){
                if (res.code !== 200){
                    Utils.errorToast(res.msg);
                    return;
                }
            });
        });


    });
</script>
